import random
secret = random.randint(1,100)

print ("猜数字游戏开始了！！")

print ("猜1到100之间的一个数哦！")

print ("准备好了吗？")

print ("开始！")

tmp = input("请选择难度（1—3）：")

# print ("1")

while tmp.isdigit() == False:
    # print("2")

    tmp = input("请输入数字：")

level = int(tmp)

while level < 1 or level > 3:
    # print ("3")
    tmp = input("请输入1—3：")
    level = int(tmp)


if level == 1:
    times = 50
    print ("你选择了简单难度，有50次机会，把握住机会吧！")

elif level == 2:
    times =30
    print ("你选择了普通难度，有30次机会，把握住机会吧！")

elif level == 3:
    times = 10
    print ("你选择了困难难度，有10次机会，祝你好运！")

tmp2 = 0
gusNum = 0

while tmp2 != times and gusNum !=secret:
    tmp3 = input("第" + str(tmp2 + 1) + "猜想:")
    
    while tmp3.isdigit() == False:
        # print("2")

        tmp3 = input("请输入数字：")

    gusNum = int(tmp3)

    if gusNum == secret:
        print ("恭喜你猜对了")

    elif gusNum < secret:
        print ("你猜的小了！")
        tmp2 = tmp2 + 1

    else:
        print ("你猜的大了！")
        tmp2 = tmp2 + 1

print ("结束了") 
       
